/*
 * Copyright (C) 2021 Fastjrun, Inc. All Rights Reserved.
 */
package com.fastjrun.security.service.impl;

import com.fastjrun.share.demo.entity.SysUser;
import com.fastjrun.share.demo.entity.SysUserExample;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("userDetailsService")
public class CustomUserDetailsService extends AbstractUserDetailsService {


    @Override
    public SysUser findSysUser(String usernameOrMobileOrOpenid) {

        SysUserExample sysUserExample = new SysUserExample();

        sysUserExample.createCriteria().andUsernameEqualTo(usernameOrMobileOrOpenid);
        List<SysUser> sysUserList = sysUserDao.selectByExample(sysUserExample);
        if (sysUserList != null && sysUserList.size() > 0) {
            return sysUserList.get(0);
        }
        return null;
    }
}
